/*** 
Replication Material for
Abou-Chadi/Wagner (2019): 
Electoral Fortunes of Social Democratic Parties: Do Second Dimension Positions matter?
Journal of European Public Policy 
***/

use "jepp_socdem_replication.dta", clear


***JEPP R&R***
**Table 1**
eststo: melogit vote_ml position  mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

eststo: melogit vote_ml  galtan mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

eststo: melogit vote_ml position galtan mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

esttab using "Immigration follow-up/paper/table1jepp.tex", b(3) se star(* 0.05 ** 0.01) replace label nodep ///
mtitles("EU only" "GAL-TAN only" "EU and GAL-TAN") nobaselevels order(position galtan lrecon) ///
transform(ln*: exp(@) exp(@)) eqlabels("" "sd(country)" "sd(Country-Study)", none)
eststo clear

*Table 1 Predicted Probabilities*

melogit vote_ml position  mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(position=(5 (.2) 7))
marginsplot,  title("")  xtitle("EU Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote")  ///
 addplot( hist position if e(sample), fraction fcolor(none) legend(off))
 graph export "Immigration follow-up/paper/margeffectsposition.pdf", as(pdf) width(3000)

 
melogit vote_ml  galtan mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(galtan=(2(.5)5.5))
marginsplot, title("")  xtitle("GAL/TAN Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
 addplot( hist galtan if e(sample), fraction fcolor(none) legend(off))
 graph export "Immigration follow-up/paper/margeffectsgaltan.pdf", as(pdf) width(3000)

 

melogit vote_ml  c.position##c.position mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(position=(5 (.2) 7))
marginsplot,  title("")  xtitle("EU Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote")  ///
 addplot( hist position if e(sample), fraction fcolor(none) legend(off))

 
 
melogit vote_ml  c.galtan##c.galtan mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(galtan=(2(.5)5.2))
marginsplot, title("")  xtitle("GAL/TAN Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
 addplot( hist galtan if e(sample), fraction fcolor(none) legend(off))
 
 

**Competitive context**
eststo: melogit vote_ml  c.position##c.position mig_rate MLingov gdpchange lrecon positionMR radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

eststo: melogit vote_ml  c.position##c.position mig_rate MLingov gdpchange lrecon rival_europe radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

eststo: melogit vote_ml  c.galtan##c.galtan mig_rate MLingov gdpchange lrecon galtanMR radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

eststo: melogit vote_ml  c.galtan##c.galtan mig_rate MLingov gdpchange lrecon rival_galtan radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

esttab using "Immigration follow-up/paper/tablecomp.tex", b(3) se star(* 0.05 ** 0.01) replace label nodep ///
mtitles("EU only" "GAL-TAN only" "EU and GAL-TAN") nobaselevels order(position galtan lrecon) ///
transform(ln*: exp(@) exp(@)) eqlabels("" "sd(country)" "sd(Country-Study)", none)
eststo clear


melogit vote_ml  c.galtan##c.galtan mig_rate MLingov gdpchange lrecon galtanMR radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(galtan=(2(.5)5.5))
marginsplot, title("")  xtitle("GAL/TAN Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
 addplot( hist galtan if e(sample), fraction fcolor(none) legend(off))
 
 
melogit vote_ml  c.galtan##c.galtan mig_rate MLingov gdpchange lrecon rival_galtan radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(galtan=(2(.5)5.5))
marginsplot, title("")  xtitle("GAL/TAN Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
 addplot( hist galtan if e(sample), fraction fcolor(none) legend(off))
 
 
melogit vote_ml  c.position##c.position mig_rate MLingov gdpchange lrecon positionMR radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(position=(5 (.2) 7))
marginsplot,  title("")  xtitle("EU Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote")  ///
 addplot( hist position if e(sample), fraction fcolor(none) legend(off))
 
 
melogit vote_ml  c.position##c.position mig_rate MLingov gdpchange lrecon rival_europe radrightbin  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:
margins, at(position=(5 (.2) 7))
marginsplot,  title("")  xtitle("EU Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote")  ///
 addplot( hist position if e(sample), fraction fcolor(none) legend(off))

 
***Micro Interactions***
*Appendix Table*
eststo: melogit vote_ml c.position##c.agea c.galtan##c.agea c.lrecon##c.agea  ///
mig_rate MLingov gdpchange ///
lrscale i.edusimple i.class8 union_member rural  /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 

eststo: melogit vote_ml c.position##i.edusimple c.galtan##i.edusimple c.lrecon##i.edusimple  ///
mig_rate MLingov gdpchange ///
lrscale i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear:

eststo: melogit vote_ml c.position##i.class8 c.galtan##i.class8 c.lrecon##i.class8  ///
mig_rate MLingov gdpchange ///
lrscale i.edusimple union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 

esttab using "Immigration follow-up/paper/tableAppjepp.tex", b(3) se star(* 0.05 ** 0.01) replace label nodep ///
mtitles("Age" "Education" "Class") nobaselevels order(position galtan lrecon) ///
transform(ln*: exp(@) exp(@)) eqlabels("" "sd(country)" "sd(Country-Study)", none)
eststo clear

**Galtan**

melogit vote_ml c.position##c.agea c.galtan##c.agea c.lrecon##c.agea  ///
mig_rate MLingov gdpchange ///
lrscale i.edusimple i.class8 union_member rural  /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(agea=(20 (10) 80) galtan=(2 5))
marginsplot,title("")  xtitle("Age")  ///
 recast(line) recastci(rline) ciopts(lpattern(dash))    ///
 ytitle("Predicted Probability SD Vote")

melogit vote_ml c.position##c.agea c.galtan##c.galtan##c.agea c.lrecon##c.agea  ///
mig_rate MLingov gdpchange ///
lrscale i.edusimple i.class8 union_member rural  /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(agea=(20 (10) 80) galtan=(2 5))
marginsplot,title("")  xtitle("Age")  ///
 recast(line) recastci(rline) ciopts(lpattern(dash))    ///
 ytitle("Predicted Probability SD Vote")
 
 
melogit vote_ml c.position##i.edusimple c.galtan##i.edusimple c.lrecon##i.edusimple  ///
mig_rate MLingov gdpchange ///
lrscale class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(edusimple=(1 2 3) galtan=(2 5))
marginsplot, horizontal recast(scatter)

melogit vote_ml c.position##i.class8 c.galtan##i.class8 c.lrecon##i.class8  ///
mig_rate MLingov gdpchange ///
lrscale i.edusimple union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(class=(1 (1) 8) galtan=(2 5))
marginsplot, horizontal recast(scatter)

 
**EU Position** 
melogit vote_ml c.position##c.agea c.galtan##c.agea c.lrecon##c.agea  ///
mig_rate MLingov gdpchange ///
lrscale i.edusimple i.class8 union_member rural  /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(agea=(20 (10) 80) position=(5 7))
marginsplot, title("")  xtitle("Age")  ///
 recast(line) recastci(rline) ciopts(lpattern(dash))    ///
 ytitle("Predicted Probability SD Vote")

melogit vote_ml c.position##i.edusimple c.galtan##i.edusimple c.lrecon##i.edusimple  ///
mig_rate MLingov gdpchange ///
lrscale class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(edusimple=(1 2 3) position=(5 7))
marginsplot, horizontal recast(scatter) 
 
melogit vote_ml c.position##i.class8 c.galtan##i.class8 c.lrecon##i.class8  ///
mig_rate MLingov gdpchange ///
lrscale i.edusimple union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(class=(1 (1) 8) position=(5 7))
marginsplot, horizontal recast(scatter) 


***Immigration***
melogit vote_ml immigrate_policy mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || cyear:
margins, at(immigrate_policy=(3 (.5) 6.5))
marginsplot,  title("")  xtitle("Immigration Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
 addplot( hist immigrate_policy if e(sample), fraction fcolor(none) legend(off)) 

melogit vote_ml c.immigrate_policy##c.immigrate_policy mig_rate MLingov gdpchange lrecon  ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || cyear:
margins, at(immigrate_policy=(3 (.5) 6.5))
marginsplot,  title("")  xtitle("Immigration Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
 addplot( hist immigrate_policy if e(sample), fraction fcolor(none) legend(off)) 


 
 
 *** Non-voters included
 
melogit vote_ml2 c.position##c.position mig_rate MLingov gdpchange lrecon   ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(position=(5 (.2) 7))
marginsplot,  title("")  xtitle("EU Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
  addplot( hist position if e(sample), fraction fcolor(none) legend(off))

melogit vote_ml2 c.galtan##c.galtan mig_rate MLingov gdpchange lrecon   ///
lrscale i.edusimple i.class8 union_member rural agea /// 
gndr rlgatnd  /// 
[pweight=dweight] || country: || cyear: 
margins, at(galtan=(2(.2)5))
marginsplot, title("")  xtitle("GAL/TAN Position")  ///
 recast(line) recastci(rline)  ciopts(lpattern(dash) lcolor(black))   ///
 ytitle("Predicted Probability SD Vote") ///
   addplot( hist galtan if e(sample), fraction fcolor(none) legend(off))
 



 
